#define _CRT_SECURE_NO_WARNINGS 1



#include<stdio.h>

int fun(int n)
{
	int count = 0;
	while (n > 0)
	{
		count++;
		n -= 500;
	}
	return count;
}
int main()
{
	int n = 0, ret = 0;
	char m = 0;
	scanf("%d %c", &n, &m);
	if (n <= 1000)
	{
		if (m == 'y')
			printf("13\n");
		else
			printf("8\n");
	}
	else if (n > 1000)
	{
		ret = fun(n - 1000);
		if (m == 'y')
			printf("%d\n", 13 + ret * 4);
		else
			printf("%d\n", 8 + ret * 4);
	}

	return 0;
}